<?php
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
$type=$_GET["type"];
$uin=$_GET["uin"];
$qq=$_GET['qq'];
$jf=$_GET['jf'];
if($type=="hz"){
    exit(hz($uin));}
if($type=="c"){
    exit(c($uin));}
if($type=="dl"){
    exit(dl($uin));}
if($type=="cdl"){
    exit(cdl($uin));}
if($type=="dlzt"){
    exit(dlzt($uin));}
if($type=="hzxx"){
    exit(hzxx($uin));}
if($type=="hzqd"){
    exit(hzqd($uin));}
if($type=="hzjs"){
    exit(hzjs($uin));}
if($type=="lqfk"){
    exit(lqfk($uin));}
if($type=="lqss"){
    exit(lqss($uin));}
if($type=="jfzs"){
    exit(jfzs($uin,$qq,$jf));}
if($type=="tmtx"){
    exit(tmtx($uin));}
if($type=="kbwm"){
    exit(kbwm($uin));}
if($type=="scss"){
    exit(scss($uin));}
if($type=="scly"){
    exit(scly($uin));}
if($type=="plgb"){
    exit(plgb($uin));}
if($type=="lygb"){
    exit(lygb($uin));}
if($type=="jjtj"){
    exit(jjtj($uin));}
if($type=="ycss"){
    exit(ycss($uin));}
if($type=="zcsj"){
    exit(zcsj($uin));}
if($type=="tbgx"){
    exit(tbgx($uin));}
if($type=="hysc"){
    exit(hysc($uin,$qq));}
if($type=="zhye"){
    exit(zhye($uin,$qq));}

function hz($uin){
//登录互赞
$url="https://www.huzanle.com/api/gethzqr?bzqqnum=".$uin;
$data=get_curl($url);
$json = json_decode($data, true);
if($josn["code"]="1"){}else{exit("抱歉，获取出错。");}
$id=$json["data"]["id"];
file_put_contents("data/huzanbao/hz/".$uin.".dat",$id);
$img=base64_decode(str_replace(array('data:image/png;base64,'), array('',''), $json["data"]["qrcode"]));
file_put_contents('data/huzanbao/tp/' . $id . '.png', $img);
echo "".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/tp/".$id.".png";
}

function c($uin){
//查登录互赞
$id=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/hz/".$uin.".dat");
$url="https://www.huzanle.com/api/hzqrlogin?id=".$id."&r=".time();
$data=get_curl($url);
return str_replace('<br>','\n',$data);
}

function dl($uin){
//登录中心
$url="https://www.huzanle.com/api/qrc?r=".time();
$data=get_curl($url,0,0,"ck_ivq=12385811");
$json = json_decode($data, true);
if($josn["code"]="1"){}else{exit("抱歉，获取出错。");}
$id=$json["data"]["qrsig"];
file_put_contents("data/huzanbao/dl/".$uin.".dat",$id);
$img=base64_decode(str_replace(array('data:image/png;base64,'), array('',''), $json["data"]["img"]));
file_put_contents('data/huzanbao/tp/' . time() . '.png', $img);
echo "".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/tp/".time().".png";
}


function cdl($uin){
//查登录中心
$id=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/dl/".$uin.".dat");
$url="https://www.huzanle.com/api/qrlogin?qrsig=".$id."&r=".time();
$data=get_curl($url,0,0,"ck_ivq=12385811",1);
preg_match('/uin":"(.*?)"/', $data, $uin);
preg_match('/ck_remenber=(.*?);/', $data, $ck);
preg_match('/PHPSESSID=(.*?);/', $data, $sid);
if($uin[1]==''){
echo $data;
}else{
$shuju="data/huzanbao/key/".$uin[1].".dat";
$handle = fopen($shuju, 'w') or die('Cannot open file: '.$shuju);
fwrite($handle, 'ck_remenber='.$ck[1].'; PHPSESSID='.$sid[1].';');
$data=get_curl("https://www.huzanle.com/user",1,0,'ck_remenber='.$ck[1].'; PHPSESSID='.$sid[1].';');
preg_match('/<span>积分 <b class="user_points">(.*?)<\/b>/', $data, $jf);
preg_match('/<h3>(.*?)<\/h3>/', $data, $name);
preg_match('/<h3 class="user-type">(.*?)<\/h3>/', $data, $hy);
$jf=$jf[1];
$name=$name[1];
$hy=$hy[1];
echo '登录成功\r昵称:'.$name.'\r账号:'.$uin.'\r积分:'.$jf.'\n'.$hy.'';
}
}

function dlzt($uin){
//登录状态查询
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/user/exchange","sid=".$id."&input%5Bqqnum%5D=".$uin,0,$ck);
$json = json_decode($data, true);
$filename = 'data/huzanbao/key/'.$uin.'.dat';
if(file_exists($filename==false)){ 
echo "0";
}else if($json['code']=='0'){
echo "0";
}else{
echo "1";
}
}

function hzxx($uin){
//互赞信息
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/user",1,0,$ck);
preg_match('/<span>积分 <b class="user_points">(.*?)<\/b>/', $data, $jf);
preg_match('/<h3>(.*?)<\/h3>/', $data, $name);
preg_match('/<h3 class="user-type">(.*?)<\/h3>/', $data, $hy);
$jf=$jf[1];
$name=$name[1];
$hy=$hy[1];
echo "昵称:".$name."\r";
echo "账号:".$uin."\r";
echo "积分:".$jf."\r";
echo $hy;
}

function hzqd($uin){
//互赞签到
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/user/sign",1,0,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function hzjs($uin){
//互赞加速
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/user/speed",1,0,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function lqfk($uin){
//领取访客
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/user/visitor",1,0,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function lqss($uin){
//领取说说
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/user/shuoshuo","bzqqnum=".$uin."&num=1",1,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function jfzs($uin,$qq,$jf){
//积分赠送
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/user/give_point","szqqnum=".$qq."&num=".$jf."",1,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function tmtx($uin){
//透明头像
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/qzone/tmtx",1,0,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function kbwm($uin){
//空白网名
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/qzone/kbwm",1,0,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function scss($uin){
//删除说说
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/qzone/delss",1,0,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function scly($uin){
//删除留言
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/qzone/delly",1,0,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function plgb($uin){
//评论关闭
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/qzone/plsh",1,0,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function lygb($uin){
//留言关闭
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/qzone/lysh",1,0,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function jjtj($uin){
//拒绝添加
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/qzone/jjtj",1,0,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function ycss($uin){
//隐藏搜索
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/qzone/ycss",1,0,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function zcsj($uin){
//注册时间
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/qzone/regtime",1,0,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function tbgx($uin){
//特别关心
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/qzone/tbgx",1,0,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function hysc($uin,$qq){
//好友时长
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/qzone/hysc","qq=".$qq."",0,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function zhye($uin){
//账户余额
$ck=get_curl("".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao/key/".$uin.".dat");
$data=get_curl("https://www.huzanle.com/api/qzone/money",1,0,$ck);
$json = json_decode($data, true);
echo $json["msg"];
}

function get_curl($url,$post=0,$referer=0,$cookie=0,$header=0,$ua=0,$nobaody=0,$split=0)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$httpheader[] = "Accept:*/*";
$httpheader[] = "Accept-Encoding:gzip,deflate,sdch";
$httpheader[] = "Accept-Language:zh-CN,zh;q=0.8";
$httpheader[] = "Connection:keep-alive";
$httpheader[] = "Referer: ".$http_type."".$_SERVER["HTTP_HOST"]."/api/data/huzanbao";
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
if($post){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if($header){
curl_setopt($ch, CURLOPT_HEADER, TRUE);
}
curl_setopt($ch, CURLOPT_COOKIE, "ck_ivq=12385811");
if($cookie){
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
if($referer){
curl_setopt($ch, CURLOPT_REFERER, $referer);
}
if($ua){
curl_setopt($ch, CURLOPT_USERAGENT,$ua);
}else{
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.152 Safari/537.36');
}
if($nobaody)
{
curl_setopt($ch, CURLOPT_NOBODY,1);
}
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$ret = curl_exec($ch);
if ($split) {
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($ret, 0, $headerSize);
$body = substr($ret, $headerSize);
$ret=array();
$ret['header']=$header;
$ret['body']=$body;
}

curl_close($ch);
return $ret;
}
?>